package com.kindel.controller.type;

import com.kindel.controller.book.BookController;
import com.kindel.model.book.BookModel;
import com.kindel.model.type.BookTypeModel;
import com.kindel.service.type.BookTypeService;
import io.swagger.annotations.*;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by winte on 2017/8/28.
 */
@Controller
@RequestMapping("kindel/admin/type")
@EnableAutoConfiguration
@Api(value = "图书类目接口", description = "")
public class BookTypeController {
    private Logger logger = Logger.getLogger(BookController.class);
    @Autowired
    private BookTypeService bookTypeService;

    @RequestMapping(value = "loadBookType",method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation(value = "查询所有书籍类目，不需要传递参数")
    public List<BookTypeModel> loadBookType(){
        List<BookTypeModel> list=new ArrayList<>();
        list=bookTypeService.loadBookType();
        return list;
    }

    @RequestMapping(value = "loadBookTypeByName",method = RequestMethod.POST)
    @ResponseBody
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", dataType = "String", name = "name", value = "类目名", required = false)
    })
    @ApiOperation(value = "根据类名查询书籍")
    public List<BookModel> loadBookTypeByName(String name){
        List<BookModel> list=new ArrayList<>();
        list=bookTypeService.loadBookTypeByName(name);
        return list;
    }
}
